/**
 * Created by youngpan on 2017/1/6.
 */
//如果需要一些服务,过滤器，确保服务，和过滤器被加载。
define(['app'], function (app) {
    app.controller('brandTitleCtrl', ['$scope', '$http', function ($scope, $http) {
        $scope.active = -1;
        $scope.brands = [];
        $http({
            method: "get",
            url: "http://192.168.127.222:9090/api/getbrandtitle"
        }).then(function (data) {
            $scope.title = data.data.result;
        }, function (err) {
            console.log(err);
        });
        $scope.getBrand = function (id) {
            $scope.active = $scope.active === -1 ? id : -1;
            $http({
                method: "get",
                url: "http://192.168.127.222:9090/api/getbrand",
                params: {
                    "brandtitleid": id
                },
                cache: "true"
            }).then(function (data) {
                $scope.brands[id] = data.data.result;
                console.log(data.data.result);
            }, function (err) {
                console.log(err);
            })
        }
    }]);
    app.controller('branTitleDetailCtrl',['$scope','$http','$routeParams',function($scope,$http,$routeParams){
        $scope.id = $routeParams.id;
        $http({
            method:'get',
            url:'http://192.168.127.222:9090/api/getbrandproductlist',
            params: {
                "brandtitleid": $scope.id
            }
        }).then(function(data){
            $scope.data = data.data.result;
        },function(err){
            console.log(err);
        })
    }])

});